/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package seso;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.RoundRectangle2D;

/**
 *
 * @author Administrator
 */
public class RComboBoxBorder extends javax.swing.JLabel {

    private boolean focus_Gained = false, mouse_Entered = false;
    private final int arcWH = 8;

    public RComboBoxBorder() {
        super();
        initControl();
    }

    private void initControl() {
        setOpaque(false); // must be false
        setBorder(null);
        setFont(new Font("Arial Unicode", Font.PLAIN, 128));
    }

    public void doRePaint(boolean focus_Gained) {
        this.focus_Gained = focus_Gained;
        repaint();
    }

    @Override
    protected void paintComponent(Graphics g) {

        Graphics2D g2d = (Graphics2D) g;
        int width = getWidth();
        int height = getHeight();

        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

        RoundRectangle2D.Double rect = new RoundRectangle2D.Double(0, 0, width, height, arcWH, arcWH);
        g2d.clip(rect);

        setText("█"); // 左边显示一个白色的前景色空白
        super.paintComponent(g);
    }

    @Override
    protected void paintBorder(java.awt.Graphics g) {
        RoundRectangle2D.Double rect;
        Graphics2D g2d = (Graphics2D) g;
        int width = getWidth();
        int height = getHeight();
        
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);


        g2d.setColor(new Color(0, 0, 0));
        rect = new RoundRectangle2D.Double(3, 3, width - 7, height - 7, arcWH, arcWH);
        g2d.draw(rect);

        g2d.setColor((focus_Gained) ? new Color(136, 178, 96) : getParent().getBackground());
        rect = new RoundRectangle2D.Double(2, 2, width - 5, height - 5, arcWH, arcWH);
        g2d.draw(rect);

        g2d.setColor((focus_Gained) ? new Color(196, 229, 154) : getParent().getBackground());
        rect = new RoundRectangle2D.Double(1, 1, width - 3, height - 3, arcWH, arcWH);
        g2d.draw(rect);

        g2d.setColor((focus_Gained) ? new Color(196, 229, 154) : getParent().getBackground());
        rect = new RoundRectangle2D.Double(0, 0, width - 1, height - 1, arcWH, arcWH);
        g2d.draw(rect);
    }
}
